import Vue from 'vue'
import Vuex from 'vuex'
import CityModule from './module/CityModule'
import TabbarModule from './module/TabbarModule'
import CinemaModule from './module/CinemaModule'
import createPersistedState from 'vuex-persistedstate'
// import http from '@/util/http'

Vue.use(Vuex)
// store '全局'的对象
export default new Vuex.Store({
  plugins: [createPersistedState()],
  // 公共状态
  state: {

  },
  // 集中式修改状态-被监控了
  mutations: {

  },
  // 异步
  actions: {

  },
  // 各个模块-火车组装
  modules: {
    CityModule,
    TabbarModule,
    CinemaModule
  }
})
// store 只是存在内存中的
// store 配置 持久化
/* // store '全局'的对象
export default new Vuex.Store({
  state: {
    cityId: '440300',
    cityName: '深圳',
    isTabbarShow: true,

    cinemaList: []
  },
  // 集中式修改状态-被监控了
  mutations: {
    changeCityName (state, name) {
      // console.log('111')
      state.cityName = name
    },
    changeCityId (state, cityId) {
      state.cityId = cityId
    },
    handleTabbarShowFalse (state) {
      state.isTabbarShow = false
    },
    handleTabbarShowTrue (state) {
      state.isTabbarShow = true
    },
    setCinemaList (state, cinemaList) {
      state.cinemaList = cinemaList
    },
    clearCinemaList (state) {
      state.cinemaList = []
    }
  },
  actions: {
    getCinemaList (store, cityId) {
      return http({
        url: `/gateway?cityId=${cityId}&ticketFlag=1&k=5132840`,
        headers: {
          'X-Host': 'mall.film-ticket.cinema.list'
        }
      }).then(res => {
        // console.log(res.data)
        store.commit('setCinemaList', res.data.data.cinemas)
      })
    }
  },
  modules: {
  }
}) */

// store 只是存在内存中的
// store 配置 持久化
